<div class="profile_page"><?php
//pr($user);
	$authedUser = $session->read('Auth.User');
	$ownProfile = false;
	if($user['User']['id']== $authedUser['id'])
	{
		$ownProfile = true;
	}
?>
<!-- recipe profile code starts here. -->
<?php if(!empty($user))
{?>
	<?php if($ownProfile)
	{?>
		<?php echo $html->link(__('Edit Profile'),('/users/editProfile'),array('class'=>'action_link button pull-right'));?>		
				
	<?php }elseif(!empty($authedUser)){
	?>
		<?php echo $html->link(__('Send message'),'/messages/send/'.$user['User']['id'].'/User',array('class'=>'action_link button pull-right')).'<br />';?>
	<?php }?>
	<div class="clear"></div>
	
	
	<!-- user's count data code stats here -->
	<div class="line">
		<div class="col-xs-12 col-md-4">
			<div class="profile_stats">
				<?php echo $html->image($user['User']['avatar'],array('thumb'=>array('crop'=>true,'width'=>80,'height'=>80)));?><br/>
				
				<hr>				
				<?php if($ownProfile == false)
				{?>

					<i class="fa fa-file"> </i><?php echo $html->link(sprintf(__('%s Listings submitted'),$user['User']['listing_count']),$user['User']['profile_links']['listings'],array())?><br/>
					<i class="fa fa-star"> </i><?php echo $html->link(sprintf(__('%s Reviews submitted'),$user['User']['review_count']),$user['User']['profile_links']['reviews'],array())?> <br/>
					<i class="fa fa-heart"> </i><?php echo $html->link(sprintf(__('%s Favorite Listings'),$user['User']['fav_listing_count']),$user['User']['profile_links']['favorites'],array())?><br/>
					<i class="fa fa-camera-retro"> </i><?php echo $html->link(sprintf(__('%s Listing Images'),$user['User']['listing_asset_count']),$user['User']['profile_links']['userGallery'],array())?>	
				<?php }else{?>
					<i class="fa fa-file"> </i> <?php echo $html->link(sprintf(__('%s Listings submitted'),$user['User']['listing_count']),SiteUrl::getUrl('myListings'),array('class'=>''))?><br/>
					<i class="fa fa-star"> </i> <?php echo $html->link(sprintf(__('%s Reviews submitted'),$user['User']['review_count']),SiteUrl::getUrl('myReviews'),array('class'=>''))?><br/>
					<i class="fa fa-heart"> </i> <?php echo $html->link(sprintf(__('%s Favorite Listings'),$user['User']['fav_listing_count']),SiteUrl::getUrl('myFavorites'),array())?><br/>
					<i class="fa fa-camera-retro"> </i> <?php echo $html->link(sprintf(__('%s Listing Images'),$user['User']['listing_asset_count']),SiteUrl::getUrl('myGallery'),array())?><br/>
              <?php if(AppUtility::allowPaidListing() && cri("PaidListings.ListingPlan")->hasAnyListing($session->read("Auth.User.id"))){?>		
                    <i class="fa fa-shopping-cart"> </i> 
                        <?php echo $html->link(__("My Orders"),"/paid_listings/orders/my",array('class'=>''))?><br/>
                    <?php } ?>
                    <?php 
                    if(cr("DealConfig.enable_deals"))
                    { ?><i class="fa fa-tags"> </i><?php
                    	echo $html->link(__('My posted deals'),$html->url(array("plugin"=>"deals","controller"=>"deals","action"=>"myDeals"), true),array('class'=>''));?>
                    	<br/><i class=" fa fa-certificate "> </i><?php
                    	echo $html->link(__('My purchased deals'),$html->url(array("plugin"=>"deals","controller"=>"deal_orders","action"=>"myDeals"), true),array('class'=>''));
                    }
                    if(cr("EventConfig.enable_events"))
                    { ?><br/><i class="fa fa-calendar"> </i><?php
                    	echo $html->link(__('My posted events'),$html->url(array("plugin"=>"events","controller"=>"events","action"=>"my"), true),array('class'=>''));
                    }
                    ?>
                    
                    
                    
                <?php }?>
				<?php if($allowReviewComment)
				{?><br/>
					<i class="fa fa-comment"> </i><?php echo $html->link(sprintf(__('%s Comments'),$user['User']['review_comment_count']),SiteUrl::getUrl('userReviewComments',array('user'=>$user['User']['slug'])),array('class'=>''));?>
				<br/>
				
				<?php }?>
				
			</div>
		</div>
		<!-- user's count data code ends here -->
			
		<div class="col-xs-12 col-md-6 user_info">
			<strong>
				<?php echo __('Registration Date')?> :
			</strong>
			<?php echo date('Y-m-d',strtotime($user['User']['created']));?><br/>
			
			<strong>
				<?php echo __('Last Login Date')?> :
			</strong>
			<?php echo date('Y-m-d',strtotime($user['User']['last_login_date']));?><br/>
		<?php 
		//code to show custom field starts here
		$customFields = $fieldPropertiesObj->getFields();
		$fieldToShow = $customFields;
		if($fieldToShow)
		{
			foreach($fieldToShow as $field)
			{?>
				<strong>
					<?php echo $userModel->getFieldProperty($field, 'label')?> : 
				</strong>
				<?php 
					$value = $userModel->showValue($field, $user['User']);
					
					$dbType = $fieldPropertiesObj->getSchemaType($field);
					if(empty($value))
					{
						$value = __('N/A');
					}
					?>
					<?php echo $value;?><br/>
				<?php 
			}
		}
		//code to show custom field ends here	
		?>	
			
	
		</div>
	</div>

		
	<?php echo $this->element('user_latest_listings',array('id'=>$user['User']['id'],'user'=>$user))?>
	<?php echo $this->element('user_favourite_listings',array('id'=>$user['User']['id'],'user'=>$user))?>
	<?php echo $this->element('user_latest_reviews',array('id'=>$user['User']['id'],'user'=>$user))?>
<?php }?>	
	
<!-- recipe profile code ends here. -->
</div>